package com.atguigu.tingshu.order.adapter.impl;

import com.atguigu.tingshu.common.rabbit.constant.MqConst;
import com.atguigu.tingshu.common.rabbit.service.RabbitService;
import com.atguigu.tingshu.order.adapter.PayWay;
import com.atguigu.tingshu.order.service.OrderInfoService;
import com.atguigu.tingshu.vo.order.OrderInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Description:
 *
 * @author Yanxinhao on 2025/2/11
 */
@Component
public class WxPayWayImpl implements PayWay {

    @Autowired
    private OrderInfoService orderInfoService;

    @Autowired
    private RabbitService rabbitService;

    @Override
    public Boolean isThisWay(String payWay) {
        return "1101".equals(payWay);
    }

    @Override
    public void payWay(OrderInfoVo orderInfoVo, String orderNo, Long userId) {
        //1.保存订单信息
        orderInfoService.saveOrderInfo(orderInfoVo,orderNo,userId);

        //2.发送消息到延时队列中，等待30分钟后，如果没有支付，则讲订单状态为0901（未支付）的修改为0903（已取消）
        rabbitService.sendDealyMessage(MqConst.EXCHANGE_CANCEL_ORDER,MqConst.ROUTING_CANCEL_ORDER,orderNo,60 * 30);

    }
}